<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>领取礼包</title>
    <script type="text/javascript" src="/jquery/jquery-2.2.4.min.js"></script>
    <script type="text/javascript" src="/js/util.js"></script>
</head>
<style>
    body {
        margin: 0;
        font-family: Medium;
    }

    .gift_box {
        max-width: 720px;
        min-width: 320px;
        width: 100%;
        left: 50%;
        transform: translateX(-50%);
        top: 0;
        overflow: hidden;
        position: absolute;
        background: url("/static/image/inviteNewImg/res_bg.png") no-repeat;
        background-size: 100% 100%;
    }

    .bg img {
        width: 100%;
        height: 100%;
    }

    .gift_detail {
        position: relative;
        z-index: 100;
        left: 0;
        right: 0;
        top: 31px;
        bottom: 50px;
        text-align: center;
        animation: zoomIn 0.8s ease-out;
    }

    .title_img {
        margin: 0 auto;
    }

    .gift_detail .res_title {
        display: inline-block;
        width: 80%;
        margin: 0 auto;
    }

    .gift_detail .res_tip {
        width: 50%;
        margin: 10px auto 0;
    }

    .input_box .money_bg {
        width: 100%;
        height: auto;
        margin-top: -18%;
    }

    .input_box input {
        border-radius: 40px;
        width: 414px;
        height: 74px;
        line-height: 74px;
        background: #fff;
        overflow: hidden;
        padding: 0 15px;
        margin: 0 auto;
        font-size: 26px;
        text-align: center;
        border: none;
        outline: none;
        color: #B96246;
        box-shadow: 0 3px 16px 0 rgba(249, 4, 4, 0.8);
    }

    input::-webkit-input-placeholder {
        color: #B96246;
        letter-spacing: 2px;
        font-weight: 600;
    }

    input::-webkit-input-placeholder {
        color: #B96246;
    }

    input::-moz-placeholder {
        color: #B96246;
    }

    input::-moz-placeholder {
        color: #B96246;
    }

    input::-ms-input-placeholder {
        color: #B96246;
    }

    .submit {
        display: block;
        width: 524px;
        height: 168px;
        line-height: 153px;
        background: url("/image/inviteNewImg/download.png") no-repeat;
        background-size: 100% 100%;
        margin: 0 auto 30px;
        text-align: center;
        color: #ffffff;
        font-size: 40px;
        letter-spacing: 2px;
    }

    .rule {
        padding-bottom: 80px;
        height: 400px;
    }

    .input_tip {
        display: none;
        position: fixed;
        left: 48%;
        top: 40%;
        min-width: 60%;
        margin-left: -30%;
        border-radius: 4px;
        background: rgba(1, 1, 1, 0.6);
        color: #fff;
        padding: 0 10px;
        line-height: 50px;
        animation: zoomIn .3s 0.1s 1 both;
    }

    @media only screen and (max-width: 640px) {
        .input_box input {
            width: 328px;
            height: 59px;
            line-height: 59px;
            font-size: 22px;
        }

        .rule {
            height: 380px;
        }

        .submit {
            width: 419px;
            height: 134px;
            line-height: 130px;
            font-size: 36px;
        }

        .input_tip {
            line-height: 40px;
            font-size: 14px;
            top: 30%;
        }
    }

    @media only screen and (max-width: 520px) {
        .input_box input {
            width: 288px;
            height: 50px;
            line-height: 50px;
            font-size: 18px;
        }

        .rule {
            height: 330px;
        }

        .submit {
            width: 370px;
            height: 111px;
            line-height: 101px;
            font-size: 28px;
        }

        .input_tip {
            line-height: 40px;
            font-size: 14px;
            top: 25%;
        }
    }

    @media only screen and (max-width: 414px) {
        .input_box input {
            width: 226px;
            line-height: 40px;
            font-size: 16px;
            height: 40px;
        }

        .rule {
            height: 250px;
        }

        .submit {
            width: 300px;
            height: 88px;
            line-height: 84px;
            font-size: 22px;
        }

        .input_tip {
            top: 20%;
            line-height: 35px;
            font-size: 12px;
        }
    }

    @media only screen and (max-width: 325px) {
        .input_box input {
            width: 184px;
            line-height: 36px;
            font-size: 14px;
            height: 36px;
        }

        .rule {
            height: 210px;
        }

        .submit {
            width: 250px;
            height: 75px;
            line-height: 72px;
            font-size: 18px;
        }
    }

    @keyframes zoomIn {
        0% {
            opacity: 0;
            transform: scale3d(.3, .3, .3);
        }
        50% {
            opacity: 1;
            filter: alpha(opacity=100);
        }
        100% {
            opacity: 1;
            /*transform:scale3d(1,1,1)*/
        }
    }
</style>
<body>
<div class="gift_box">
    <div class="gift_detail">
        <div class="title_img">
            <img class="res_title" src="/image/inviteNewImg/res_title.png">
            <img class="res_tip" src="/image/inviteNewImg/res_tip.png">
        </div>
        <!--用户信息-->
        <div class="input_box">
            <img class="money_bg" src="/image/inviteNewImg/money.png"/>
            <input type="text" id="phone" placeholder="请输入手机号">
            <div class="submit" onclick="submitValue()">领取礼包</div>
            <span class="input_tip" id="tip"></span>
        </div>
        <!--活动规则-->
        <div class="rule">
            <iframe align="center" width="100%" height="400px" src="/invite/rule" frameborder="no" border="0"
                    marginwidth="0" marginheight="0" scrolling="no"></iframe>
        </div>
    </div>
</div>
</body>
<script>

    let category = "${category!''}";
    let app = "${app!''}";
    let inviteCode = getParam("inviteCode");


    // 提交判断数据
    function submitValue() {
        let phone = document.getElementById('phone').value;
        let tip = document.getElementById('tip');
        let phPattern = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
        if (!phPattern.test(phone)) {
            tip.innerText = '手机号错误，请重新输入!';
            setTip()
        } else {
            $.ajax({
                url: '/invite/check/phone',
                type: 'post',
                data: {category: category, app: app, inviteCode: inviteCode, phone: phone},
                async: false,
                error: function () {
                },
                success: function (arg) {
                    if (arg.success) {
                        window.location.href = "/invite/register?phone=" + phone + "&inviteCode=" + inviteCode;
                    } else {
                        if (arg.status == "555") {
                            window.location.href = "/invite/download?type=2&phone=" + phone + "&inviteCode=" + inviteCode;
                        } else {
                            tip.innerText = arg.message;
                            setTip();
                        }
                    }
                }
            });
        }
    }

    // 错误提示
    function setTip() {
        var set_time = 3;
        var tips = document.getElementById('tip');
        tips.style.display = 'block';
        var authTime = setInterval(() => {
            set_time--;
            if (set_time <= 0) {
                tips.style.display = 'none';
                clearInterval(authTime);
            }
        }, 1000);
    }
</script>
</html>
